<?php

namespace App\Http\Resources\Api;

use App\Support\ResourceCollection;

class Games extends ResourceCollection
{
    /**
     * Transform the resource collection into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return $this->collection->map([$this, 'item'])->all();
    }

    /**
     * 格式化单个数据
     *
     * @param \Modules\Xiaoyu\Models\Banner $item
     * @return array
     */
    public function item($item)
    {
        $item->users;
        if($item->users){
            foreach ($item->users as $user) {
                $user->userInfo;
            }
        }
        $item->winner;
        return $item;
    }
}
